<?php
namespace app\common\model;

use think\Model;

class Role extends BaseModel
{
    /**
     * 获取角色对应权限
     */
    public function menus($role_id)
    {
        $result = [];
        $access = model("RoleAccess")->where(["role_id" => $role_id])->select()->toArray();
        $menu_ids = array_column($access, "menu_id");
    
        if (!empty($menu_ids)) {
            $result = model("Menu")->where(["id" => array("in", $menu_ids)])->select()->toArray();
        }
        return $result;
    }
}
